package cn.edu.ldu.protocol;

import cn.edu.ldu.modules.controller.ChatHistoryController;
import cn.edu.ldu.modules.controller.ChatMemberController;
import cn.edu.ldu.modules.entity.ChatMemberEntity;
import cn.edu.ldu.views.modules.controller.UserController;
import com.alibaba.fastjson.JSONObject;

public class AddGroup {

    public AddGroup(Protocol protocol){

        ChatMemberEntity chatMemberEntity = JSONObject.parseObject(protocol.getData(), ChatMemberEntity.class);

        try {
            String result = ChatMemberController.addChatGroup(chatMemberEntity, protocol.getToken());
            protocol.setKey(result);
            protocol.setData(null);
            UserController.sendDataToUser(protocol);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

}
